home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 10534 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.7 KB

  1. Path: news.halcyon.com!usenet
  2. From: normanb@halcyon.com (Norm Bryar)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Need help with far pointers to struct in .h file
  5. Date: Fri, 08 Mar 1996 15:41:22 GMT
  6. Organization: Northwest Nexus Inc.
  7. Message-ID: <4hpkdp$sr0@news.halcyon.com>
  8. References: <4hd5bg$cvd@bert.compusmart.ab.ca>
  9. NNTP-Posting-Host: blv-pm3-ip14.halcyon.com
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. cpettica@compusmart.ab.ca (Chris) wrote:
  13.  
  14. >When I try to run my program I get a general protection exception.  It dies 
  15. >in this function, which of course is the first one called when I select 
  16. >checkers.  I have marked the line, which is the first line executed.
  17.  
  18. >Do I have to declare the array somewhere(WM_CREATE ??) in the cpp file?
  19.  
  20.  
  21. >void fnInitCheckerArray(LPARAM lParam)
  22. >{
  23. >        GAMEDATA far * lPtr;
  24. >    lPtr = (GAMEDATA far *)lParam;
  25.  
  26. >    for (int iRow = 0; iRow < CHECKER_ROWS; iRow++)
  27. >        for(int iColumn = 0; iColumn < CHECKER_COLUMNS; iColumn++)
  28. >        {
  29. >            if ((iRow + iColumn)%2)
  30. >            {
  31. >            if(iRow < 3)
  32. >                lPtr->aiCheckerArray[iRow][iColumn] = 1; 
  33. >                        else if (iRow > 4)
  34. >                lPtr->aiCheckerArray[iRow][iColumn] = 2; 
  35. >                else
  36. >                lPtr->aiCheckerArray[iRow][iColumn] = 0; 
  37. >            }
  38. >            else
  39. >----------------->>>>>>        lPtr->aiCheckerArray[iRow][iColumn] = -1; 
  40. >        }
  41. >    return;
  42. >}
  43.  
  44.  
  45. >Thanks in advance
  46. >Chris
  47.  
  48. O.K., it dies on the first access of lPtr->aiCheckerArray, iRow =
  49. iColumn = 0?  It very much sounds like either lParam isn't pointing to
  50. a real GAMEDATA or if it does point to a GAMEDATA, the aiCheckerArray
  51. wasn't properly allocated.
  52.  
  53. Where did lParam come from, was it passed through to WM_CREATE, which
  54. I assume is the  fnInitCheckerArray caller, by CreateWindowParam()?  
  55.  
  56.                         --Norm 
  57.  
  58.